package com.sky.controller.user;

import com.sky.constant.BusinessStatusConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "查询营业状态-用户端")
@RequestMapping("/user/shop")
public class ShopController {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @GetMapping("/status")
    @ApiOperation("查询营业状态")
    public Result queryShopStatus(){
        String status = redisTemplate.opsForValue().get(BusinessStatusConstant.BUSINESS_STATUS_KEY);
        if (status == null && "".equals(status)) {
            return Result.success(0);
        }
        return Result.success(Integer.parseInt(status));
    }
}
